package com.suntop.carousel.qlmediaplay.adapter;

import android.util.Log;

import com.suntop.carousel.qlmediaplay.bean.Option;
import com.suntop.carousel.qlmediaplay.fragement.MediaFragment;
import com.suntop.carousel.qlmediaplay.fragement.NewMediaFragment;
import com.suntop.carousel.qlmediaplay.media.IMediaPlayEventListener;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;

public class FragmentBrandAdapter extends BasicFragmentBannerAdapter<Option> {

    private boolean isRestTo;

    public FragmentBrandAdapter(@NonNull FragmentActivity fragmentActivity) {
        super(fragmentActivity);
    }

    public FragmentBrandAdapter(@NonNull Fragment fragment) {
        super(fragment);
    }

    public FragmentBrandAdapter(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle) {
        super(fragmentManager, lifecycle);
    }

    public FragmentBrandAdapter setRestTo(boolean restTo) {
        isRestTo = restTo;
        return this;
    }

    @Override
    public long getItemId(int position) {
        return super.getItemId(position);
    }

    @Override
    protected Fragment getCreatefragment(int toRealPosition, Option option, IMediaPlayEventListener listener) {
        if (!isRestTo) {
            NewMediaFragment newMediaFragment = NewMediaFragment.newInstance(toRealPosition, option);
            newMediaFragment.setIMediaPlayEventListener(listener);
            return newMediaFragment;
        }else {
            MediaFragment mediaFragment = MediaFragment.newInstance(toRealPosition, option);
            mediaFragment.setIMediaPlayEventListener(listener);
            return mediaFragment;
        }
    }



}
